import 'package:flutter/material.dart';
import 'package:flutter_deer/ui/member/member_page_login.dart';
import 'package:flutter_deer/ui/member/member_page_user.dart';
import 'package:flutter_deer/ui/member/provider/member_provider.dart';
import 'package:get/get.dart';

class MemberPage extends StatefulWidget {
  const MemberPage({super.key});

  @override
  State<MemberPage> createState() => _MemberPageState();
}

class _MemberPageState extends State<MemberPage> with AutomaticKeepAliveClientMixin<MemberPage> {
  final mProvider = Get.find<MemberProvider>();

  @override
  Widget build(BuildContext context) {
    return Obx(() => Scaffold(
          body: mProvider.mUser.value == null
              ? Center(
                  child: MemberLoginPage(
                    onConfirm: (phone) => mProvider.requestMemberInfo(phone: phone),
                  ),
                )
              : const MemberPageUser(),
        ));
  }

  @override
  bool get wantKeepAlive => true;
}
